<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" type="text/css" href="<%=path %>/static/css/css.css?1" />
<link rel="stylesheet" type="text/css" href="<%=path %>/static/jquery-ui/jquery-ui.min.css" />
<script type="text/javascript" src="<%=path %>/static/js/json2.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/jquery.js"></script>
<script type="text/javascript" src="<%=path %>/static/jquery-ui/jquery-ui.min.js"></script>
<script type="text/javascript" src="<%=path %>/static/layer/layer.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/gridview.js?v=1"></script>
<script type="text/javascript" src="<%=path %>/static/js/formview.js?v=1"></script>
<script type="text/javascript" src="<%=path %>/static/js/tool.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/validate.js"></script>
<script type="text/javascript" src="<%=path %>/wechat/js/copy/ZeroClipboard.js"></script>
<SCRIPT type="text/javascript">
    $.ajaxSetup({
       async: false
    });
    <!--
	var gridSetting = {
			id:'qhdemoGrid',
			po:"QhDemo",
			title:'',
			height:'auto',
			service:"uiServices!listSimple",
			tbId:"DemoTb",
			pageInfo: {
				records: 12,//auto表示根据容器高度自动判断
				orderby : "id desc"
			},
			oper:{
                isDisplay:true,
            	operName:"",
            	url:"",
            	cssClass:"Operation",
            	width:80
            },
			fields:[
			   {	name:'id',
					hide:true
			   },{
                    name: 'id',
                    descs:"ID",
                    align:'center',
                    thstyle:"width:60px"
               },
               {
				   name: 'name',
				   descs:"名称",
				   align:'left',
				   thstyle:"width:160px"
			   },{
                   name: 'size',
                   descs:"大小",
                   align:'center',
                   thstyle:"width:100px"
               }
			   ,{
				   name: 'price',
				   descs:"价格",
				   align:'center',
				   thstyle:"width:100px"
			   }
			   ,{
               	   name: 'summary',
               	   descs:"简介",
               	   align:'left'
               }
               ,{
               	   name: 'downNum',
               	   descs:"下载次数",
               	   align:'center',
               	   thstyle:"width:80px"
               }
			]
		};
	var grid;
    $(document).ready(function(){
    	grid = new GridView("list",gridSetting,"list");
		grid.init();
		var data = [];

		grid.load({data:data});

		ajustHeight();

		$("#deleteBtn").click(function(){
		   grid.deletes("deleteMappedRoleNavis",function(ret){
              if(ret==-1){
                 layer.msg("删除失败，请重试！");
              }else{
                 layer.msg("删除" + ret.recordNum + "条记录！",function(ret){
                    grid.reload();
                 });
              }
           });
		});
    });

    //-->
</SCRIPT>
</head>

<body>
<ul class=tab_nav>
  <li>
    <a class="current" href="javascript:void(0)">试玩列表</a>
  </li>
  <li id="tab_nav_add">
    <a href="/qh/public/common/r2.htmls?page=demo/demo_edit">新建试玩</a>
  </li>
</ul>
<div class="contrainer">
<div class="rcon2" >
<table class="search_tb">
   <tr>
      <td>
         <input type="text" name="name" placeholder="名称" style="float:left" />
         <input type="button" class="searchbtn" value="" id="queryBtn" style="float:left" />
      </td>
      <td>
         <input type="button" class="btnblue" value="删除" id="deleteBtn">
      </td>
   </tr>
</table>
</div>
<div id="list" class="rbox2"></div>
</div>

<script type="text/javascript" src="<%=path %>/static/js/underscore.js"></script>
<script type='text/javascript' src='<%=path %>/static/My97DatePicker/WdatePicker.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/util.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/interface/BaseDwr.js'></script>
<script>
    $("#queryBtn").click(function(){
       var Name = $(".search_tb").find(":input[name=name]").val();

       var data = [];

       if(Name!==""){
          data.push({r:"like",name:'name',value:"%"+Name+"%"});
       }

       grid.load({data:data});
       ajustHeight();
    });
    function afterLoad_DemoTb(){
       $(".rcon2 .mtable tbody tr").each(function(){
          var id=$(this).attr("recordid");

          var html="";
          html+="<a href=<%=path %>/public/common/r2.htmls?page=demo/demo_edit&id="+id+" >编辑</a>";
          $(this).find(".Operation").html(html);

          var $name=$(this).find("td[name=name]");
          html="<a href=<%=path %>/public/common/r2.htmls?page=demo/download_list&id="+id+" >"+$name.text()+"</a>";
          $name.html(html);

          var $downNum=$(this).find("td[name=downNum]");
          $.getJSON(g_path+"/public/common/getDownNum.htmls",{id:id},function(data){
             $downNum.text(data.cnt);
          });

       });
    }

</script>
</body>
</html>